<?php 

class AdminModel extends  Model{
	public $table='blog_admin';
	public function userLogin($data){
		if (empty($data['username'])) {
			$this->error='用户名不能为空';
			return false;
		}
		if(empty($data['password'])){
			$this->error='密码不能为空';
			return false;
		}
		$user=$this->where("username='{$data['username']}'")->find();
		if (empty($user)) {
			$this->error='管理员不存在';
			return false;
		}
		if (md5($data['password'])!=$user['password']){
			$this->error='密码不正确，请重新输入';
			return false;
		}
		$_SESSION['aid']=$user['aid'];
		$_SESSION['username']=$user['username'];
		return  true;

	}
}

 ?>